var AngularJSDemo = angular.module('AngularJSDemo',[]);

// AngularJSDemo.controller('GreetingController', ['$scope', function($scope) {
//   $scope.greeting = 'Hola!';
// }]);
AngularJSDemo.controller('CartController', ['$scope', function ($scope) {
	
	$scope.items=[
	{title:'海尔冰箱',quantity:8,price:3.95},
	{title:'长虹电视',quantity:8,price:3.95},
	{title:'电饭锅',quantity:8,price:3.95}
	];

	$scope.remove=function(index){
		$scope.items.splice(index,1);
	}

	$scope.totalCart=function(){
		var total = 0;
		for(var i = 0 ; i < $scope.items.length ; i++){
			total = total + $scope.items[i].price * $scope.items[i].quantity
		}
		return total;
	}
}]);
